#include "hash_table.h"

int main(void)
{
  /* 初始化 */
  HashTable *table = init_hash_table();

  /* 添加键值对 */
  append_pair(table, 12836, "hello");
  append_pair(table, 15937, "world");
  append_pair(table, 16750, "hash");
  append_pair(table, 13276, "table");
  print_hash_table(table);

  /* 查询元素 */
  puts("");
  puts(get_value(table, 12836));
  puts(get_value(table, 15937));
  puts(get_value(table, 16750));
  puts(get_value(table, 13276));
  
  /* 删除键值对 */
  puts("");
  remove_pair(table, 12836);
  print_hash_table(table);

  /* 遍历键 */
  puts("");
  List *k_list = get_keys(table);
  int *keys = (int *)k_list->items;
  puts("Keys:");
  for (int i = 0; i < k_list->length; i++)
  {
    printf("\t%d\n", keys[i]);
  }
  destory_list(k_list);

  /* 遍历值 */
  puts("");
  List *v_list = get_values(table);
  char **values = (char **)v_list->items;
  puts("Values:");
  for (int i = 0; i < v_list->length; i++)
  {
    printf("\t");
    puts(values[i]);
  }
  destory_list(v_list);

  /* 销毁哈希表 */
  destory_hash_table(table);

  return 0;
}
